package com.qf.zyh.web.controller;

import com.github.pagehelper.PageInfo;
import com.qf.zyh.entity.Emp;
import com.qf.zyh.services.EmpSer;
import com.qf.zyh.services.Impl.EmpSerImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/page")
public class Empcount extends HttpServlet {
    EmpSer empSer = new EmpSerImpl();
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String pageIndex = req.getParameter("pageIndex");
        if (pageIndex==null||pageIndex.equals("")) {
            pageIndex="1";
        }
        PageInfo<Emp> empPage = empSer.getEmpPage(Integer.valueOf(pageIndex));
        System.out.println(empPage);
        req.setAttribute("empinfo",empPage);
        req.getRequestDispatcher("index.jsp").forward(req,resp);
    }
}
